
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0017
 * @Author : WangRuoyu 
 * @Date : 2023/9/7 16:08
 */

#include "iostream"
#include "vector"

using namespace std;

class Solution {
public:
    vector<string> res;
    string map[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

    void dfs(int x, string ans, string number) {
        if (x == number.size()) {
            res.push_back(ans);
            return;
        }
        string t = map[number[x] - '0'];
        for (int i = 0; i < t.size(); ++i) {
            dfs(x + 1, ans + t[i], number);
        }
    }

    vector<string> letterCombinations(string digits) {
        if (digits.size() != 0) {
            dfs(0, "", digits);
        }
        return res;
    }
};

int main() {
    Solution sl;
    string digits = "23";
    vector<string> res = sl.letterCombinations(digits);
    for (int i = 0; i < res.size(); ++i) {
        cout << res[i] << " ";
    }
    return 0;
}